Skip to content

Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText. - #5072

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_972617925
Open

Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText.#5072
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_972617925

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText.

Refactors the MaxText Lineage integration to use Lineage's high-level dsv3.py entry point as the unified integration point for DeepSeek-V3 execution (dense layers followed by sparse layers).

Lineage Changes:

  • Visibility: Updated learning/performance/lineage/BUILD to grant package visibility to //third_party/py/maxtext:__subpackages__.
  • Launcher: Added learning/performance/lineage/scripts/launch_dsv3_batchsplit_maxtext.sh (XManager launch script for 512-core Ghostfish TPU v7x).
  • ops.py: Added recursive tuple translation and deduplication in _map_axis and _map_set.
  • dsv3_mla.py: Resolved redundant physical_pspec sharding transformations on physical specs.

MaxText Changes:

  • lineage_adapter.py: Translates MaxText parameter structures into Lineage's typed dataclasses (DSv3WeightsPytree containing both dense MLA/MLP weights and sparse MoE weights). Manages physical mesh axis mappings, YaRN RoPE frequencies, Splash Attention kernel initialization, dynamic minimum capacity factor alignment for Pallas kernel tiles, and delegates execution directly to dsv3.dsv3.
  • Decoders: Integrated LineageAdapter (run_lineage_dsv3) into Linen Decoder and NNXDecoder to execute the full DeepSeek-V3 layer stack when use_lineage=true.
  • Cleanup: Removed vestigial remnants of the previous sparse-only integration (lineage_sparse_adapter.py, use_lineage_sparse_layers flag, and early-return branching in deepseek.py). Removed all defensive fallback branches to maintain a lean, canonical integration.
  • Configs: Updated deepseek3-671b-lineage.yml, base.yml, and types.py with use_lineage and related Lineage flags.
  • Export: Updated copy.bara.sky to exclude lineage_adapter.py, deepseek3-671b-lineage.yml, and Lineage tests from open-source export.
  • Tests: Added unit and TPU tests in lineage_adapter_test.py and lineage_adapter_tpu_test.py; updated existing MaxText test suites (batchsplit_google_test, train_compile_google_test).

Tested:
Verified via unit test suites (lineage_adapter_test, batchsplit_google_test, train_compile_google_test, lineage_adapter_tpu_test, ops_test), and XManager training runs xid/285946702

@copybara-service
copybara-service Bot force-pushed the test_972617925 branch 2 times, most recently from ccea51d to 03b1b53 Compare September 2, 2026 20:51
@copybara-service copybara-service Bot changed the title Integrate Lineage DeepSeek-V3 58 sparse layer scan into MaxText. Integrate Lineage DeepSeek-V3 model (dsv3.py) into MaxText. Sep 2, 2026
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.41379% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/layers/nnx_decoders.py 60.00% 8 Missing and 2 partials ⚠️
src/maxtext/layers/decoders.py 81.25% 4 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@copybara-service
copybara-service Bot force-pushed the test_972617925 branch 2 times, most recently from 5cfdb32 to 77ac343 Compare September 3, 2026 06:05
@copybara-service
copybara-service Bot force-pushed the test_972617925 branch 5 times, most recently from 8b25e72 to 8d2ca7b Compare September 3, 2026 23:15
Refactors the MaxText Lineage integration to use Lineage's high-level `dsv3.py` entry point as the unified integration point for DeepSeek-V3 execution (dense layers followed by sparse layers).

Lineage Changes:
* Visibility: Updated `learning/performance/lineage/BUILD` to grant package visibility to `//third_party/py/maxtext:__subpackages__`.
* Launcher: Added `learning/performance/lineage/scripts/launch_dsv3_batchsplit_maxtext.sh` (XManager launch script for 512-core Ghostfish TPU v7x).
* `ops.py`: Added recursive tuple translation and deduplication in `_map_axis` and `_map_set`.
* `dsv3_mla.py`: Resolved redundant `physical_pspec` sharding transformations on physical specs.

MaxText Changes:
* `lineage_adapter.py`: Translates MaxText parameter structures into Lineage's typed dataclasses (`DSv3WeightsPytree` containing both dense MLA/MLP weights and sparse MoE weights). Manages physical mesh axis mappings, YaRN RoPE frequencies, Splash Attention kernel initialization, dynamic minimum capacity factor alignment for Pallas kernel tiles, and delegates execution directly to `dsv3.dsv3`.
* Decoders: Integrated `LineageAdapter` (`run_lineage_dsv3`) into Linen `Decoder` and `NNXDecoder` to execute the full DeepSeek-V3 layer stack when `use_lineage=true`.
* Cleanup: Removed vestigial remnants of the previous sparse-only integration (`lineage_sparse_adapter.py`, `use_lineage_sparse_layers` flag, and early-return branching in `deepseek.py`). Removed all defensive fallback branches to maintain a lean, canonical integration.
* Configs: Updated `deepseek3-671b-lineage.yml`, `base.yml`, and `types.py` with `use_lineage` and related Lineage flags.
* Export: Updated `copy.bara.sky` to exclude `lineage_adapter.py`, `deepseek3-671b-lineage.yml`, and Lineage tests from open-source export.
* Tests: Added unit and TPU tests in `lineage_adapter_test.py` and `lineage_adapter_tpu_test.py`; updated existing MaxText test suites (`batchsplit_google_test`, `train_compile_google_test`).

Tested:
Verified via unit test suites (`lineage_adapter_test`, `batchsplit_google_test`, `train_compile_google_test`, `lineage_adapter_tpu_test`, `ops_test`), and XManager training runs xid/285946702
PiperOrigin-RevId: 972617925
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant